
namespace BattleclinicProvider
{
    using System;
    using System.Globalization;
    using EveIntel.API;
    using EveIntel.API.Base;
    using EveIntel.API.Enums;
    using System.ComponentModel.Composition;
    using EveIntel.API.Interfaces;

    /// <summary>
    /// BattleClinic intel provider
    /// </summary>
    [Provider]
    [Export(typeof(IIntelProvider))]
    public sealed class BattleclinicProvider : IntelProviderBase
    {
        private const string PLAYER_URL = "http://eve.battleclinic.com/killboard/combat_record.php?type=player&name={0}";
        private const string SOLARSYSTEM_URL = "http://eve.battleclinic.com/killboard/recent_activity.php?searchTerms={0}";

        /// <summary>
        /// Initializes a new instance
        /// </summary>
        public BattleclinicProvider()
            :base(new Guid("D9D7F2DC-DF3C-4160-9265-9D3DBCAA5C4F"))
        {
        }

        /// <summary>
        /// Obtains a data provider description
        /// </summary>
        public override string Description
        {
            get { return "eve.battleclinic.com"; }
        }
        /// <summary>
        /// Obtains the URI to navigate to
        /// </summary>
        /// <param name="type">The IntelTypeEnum value</param>
        /// <param name="args">Additional arguments needed to build the uri</param>
        /// <returns></returns>
        public override  Uri GetUri(IntelTypeEnum type, string[] args)
        {
            if (!CanProvideIntel(type)) return null;
            return new Uri(string.Format(
                CultureInfo.InstalledUICulture,
                type == IntelTypeEnum.SolarSystem ? SOLARSYSTEM_URL : PLAYER_URL,
                args[0]));
        }

       
        /// <summary>
        /// Determines if the data provider can handle a type of intel request
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public override bool CanProvideIntel(IntelTypeEnum type)
        {
            return type == IntelTypeEnum.Player || type == IntelTypeEnum.SolarSystem;
        }
    }
}